package com.zzy.excel.easyexcel;

//import cn.afterturn.easypoi.cache.ExcelCache;
//import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
//import cn.afterturn.easypoi.excel.export.template.ExcelExportOfTemplateUtil;
//import com.alibaba.excel.EasyExcel;
//import com.alibaba.excel.ExcelWriter;
//import com.alibaba.excel.write.metadata.WriteSheet;
//import org.apache.poi.ss.usermodel.Workbook;
//
//import java.io.FileOutputStream;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;

public class TestDemo {
// easy poi 模板格式为  {{a}} {{$fe:list t.name t.title    }}
//<dependency>
//       <groupId>cn.afterturn</groupId>
//       <artifactId>easypoi-spring-boot-starter</artifactId>
//       <version>4.0.0</version>
//   </dependency>

//    <!-- easypoi的支持 -->
//    <dependency>
//      <groupId>cn.afterturn</groupId>
//      <artifactId>easypoi-base</artifactId>
//      <version>3.2.0</version>
//    </dependency>
//    <dependency>
//      <groupId>cn.afterturn</groupId>
//      <artifactId>easypoi-web</artifactId>
//      <version>3.2.0</version>
//    </dependency>
//    <dependency>
//      <groupId>cn.afterturn</groupId>
//      <artifactId>easypoi-annotation</artifactId>
//      <version>3.2.0</version>
//    </dependency>

    // easy excel 2.0 版本会冲突poi 使用 map {a}  list {.name} {.id}
//    <dependency>
//    <groupId>com.alibaba</groupld>
//    <artifactId>easyexcel</artifactId>
//    <version>3.0.5</version>
//</dependency>

//    public static String templateFilePath = "";
//    public static String outPath = "";
//
//    public static void testEasyExcel() {
//        ExcelWriter excelWriter = null;
//        try {
//            Map<String, Object> mapData = new HashMap<>();
//            List<Map<String, Object>> dataList = new ArrayList<>();
//            excelWriter = EasyExcel.write(outPath).withTemplate(templateFilePath).build();
//            int sheetNumTotal = 3;
//            for (int i = 0; i < sheetNumTotal; i++) {
//                WriteSheet writeSheet = EasyExcel.writerSheet(i).build();
//                excelWriter.fill(mapData, writeSheet);
//                excelWriter.fill(dataList, writeSheet);
//                excelWriter.finish();
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        } finally {
//            System.out.println(123);
//        }
//
//    }
//
//
//    public static void exportEasyPOI(String templatePath, String outPath) {
//        try {
//            TemplateExportParams templateExportParams = new TemplateExportParams();
//            int num = 3;
//            Workbook workbookTmp = ExcelCache.getWorkbook(templatePath, new Integer[]{0}, false);
//            Integer[] sheetNum = new Integer[num];
//            String[] sheetName = new String[num];
//            for (int i = 0; i < num - 1; i++) {
//                workbookTmp.cloneSheet(0);
//            }
//            for (int i = 0; i < num; i++) {
//                sheetNum[i] = i;
//                //sheetName[i] =“测试”+i;
//                templateExportParams.setSheetNum(sheetNum);
//                templateExportParams.setSheetName(sheetName);
//                templateExportParams.setTemplateUrl(templatePath);
//                Map<Integer, Map<String, Object>> map = new HashMap<>();
//                Workbook workbook = new ExcelExportOfTemplateUtil().createExcleByTemplate(templateExportParams, map);
//                FileOutputStream fos = new FileOutputStream(outPath);
//                workbook.write(fos);
//                fos.close();
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//    }
}



